<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 17-4-13
 * Time: 23:09
 */

namespace frontend\widget;


use backend\models\Brand;
use yii\base\Widget;

class BrandLogoWidget extends Widget
{
    public function run()
    {
        $brands = $this->getBrand();
        $html = '';
        foreach ($brands as $brand){
            if(substr($brand['logo'],0,4)=='http'){
                $brandLogo = $brand['logo'];
            }else{
                $brandLogo = \Yii::$app->params['imgUrl'].$brand['logo'];
            }
            $html.='<li><a href=""><img src="'.$brandLogo.'" alt="" /></a></li>';
        }

        return $html;

    }
    /** 获取所有的商标数组 */
    public function getBrand(){
        return Brand::find()->asArray()->all();
    }
}